package cn.hxzy.course.service.impl;

import cn.hxzy.common.domain.Courseware;
import cn.hxzy.course.mapper.CoursewareMapper;
import cn.hxzy.common.response.R;
import cn.hxzy.course.service.CoursewareService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author niuyi
 * @since 2024-06-22
 */
@Service
public class CoursewareServiceImpl extends ServiceImpl<CoursewareMapper, Courseware> implements CoursewareService {
    @Autowired
    private CoursewareMapper coursewareMapper;

    @Override
    public List<Courseware> selectWareList(Integer sectionId) {
        QueryWrapper<Courseware> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("section_id", sectionId);

        List<Courseware> coursewares = coursewareMapper.selectList(queryWrapper);
        if (coursewares!=null) {
            return coursewares;
        }
        return null;

    }

    @Override
    public List<Courseware> selectCourseware(String coursewareName,Integer courseId) {
        List<Courseware> coursewares = coursewareMapper.selectCourseware(coursewareName,courseId);
        if (coursewares!=null) {
            return coursewares;
        }
        return null;
    }

    @Override
    public double selectCount(Long courseId) {
        double num = coursewareMapper.selectCount(courseId);
        return num;
    }

    @Override
    public Integer deleteCourseware(Integer coursewareId) {
        int i = coursewareMapper.deleteCourseware(coursewareId);
        return i;
    }
}
